package com.wxy.ideaplugin.action;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.wxy.ideaplugin.ui.AiCodeUi;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.io.*;
import java.util.HashMap;
import java.util.Map;

public class HelloAction extends AnAction {

    private PsiDirectory workDir;
    protected Project project;
    protected PsiDirectory containerDirectory;

    @Override
    public void actionPerformed(AnActionEvent e) {
        Project project = e.getData(PlatformDataKeys.PROJECT);
        String projectPath = project.getBasePath();
        //System.out.println("projectPath:");
        //System.out.println(projectPath);
        AiCodeUi aiCodeUi = new AiCodeUi(projectPath);
        aiCodeUi.initUi();
    }


    public PsiFile getEditingFile(AnActionEvent e) {
        project = e.getProject();
        if (null == project) {
            return null;
        }
        Editor editor = e.getData(CommonDataKeys.EDITOR);
        if (null == editor) {
            return null;
        }
        PsiFile psiFile = PsiDocumentManager.getInstance(e.getProject()).getPsiFile(editor.getDocument());
        return psiFile;
    }


}
